package Game.Spawners;

import java.util.ArrayList;
import java.util.List;

import org.newdawn.slick.SlickException;

import Game.Level;
import Game.Objects.GOTrapdoor;
import GameMath.GPoint;

/** Spawn trapdoor class
 * @author Aikidos
 */
public class SpawnTrapdoor extends SpawnerBase {

	@Override
	public void spawn(Level level) throws SlickException {
		List<GPoint> banCoords = new ArrayList<GPoint>();
		banCoords.add(level.getObjectManager().getPlayer().getCoord());
		
		if (!level.isUndergroundTown())
			banCoords.add(level.getObjectManager().getObjectsByClass("Game.Objects.GOLever")[0].getCoord());
		
		GOTrapdoor trapdoor = new GOTrapdoor(level.getObjectManager());
		if (level.isUndergroundTown()) trapdoor.open();
		
		level.getObjectManager().spawnObject(trapdoor, banCoords);
	}
	
}
